<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>菜鸟教程(runoob.com)</title>
<script>
function myFunction(){
	let bodys=document.getElementById("bodys");
    let fname = document.getElementById('fname');
    if(fname.value == 1){
        bodys.style.background = "url(image/1.png) no-repeat";
    }else if(fname.value == 2){
        bodys.style.background = "url(image/2.png) no-repeat";
    }else if(fname.value == 3){
        bodys.style.background = "url(image/3.png) no-repeat";
    }else{
        bodys.style.background = "url(image/3.png) no-repeat";
    }
}
</script>
</head>
<body id="bodys">

<p>当用户在输入字段释放一个按键时触发函数。函数将字符转换为大写。</p>
输入你的名称: <input type="text" id="fname" onkeyup="myFunction()">

</body>
</html>